package com.AC.ACJingDong;

import org.junit.Test;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

public class test1 {

    char[] num = {2,3,5};

    List<Integer> nums = new ArrayList<>();

    int[] table = {2,3,5,22,23,25,32,33,35,52,53,55,222,223,225,232,233,235,252,253,255,322,323,325,332,
            333,335,352,353,355,522,523,525,532,533,535,552,553,555,2222,2223,2225,2232,2233,2235,2252,
            2253,2255,2322,2323,2325,2332,2333,2335,2352,2353,2355,2522,2523,2525,2532,2533,2535,2552,2553,
            2555,3222,3223,3225,3232,3233,3235,3252,3253,3255,3322,3323,3325,3332,3333,3335,3352,3353,3355,
            3522,3523,3525,3532,3533,3535,3552,3553,3555,5222,5223,5225,5232,5233,5235,5252,5253,5255,5322,
            5323,5325,5332,5333,5335,5352,5353,5355,5522,5523,5525,5532,5533,5535,5552,5553,5555,22222,22223,
            22225,22232,22233,22235,22252,22253,22255,22322,22323,22325,22332,22333,22335,22352,22353,22355,
            22522,22523,22525,22532,22533,22535,22552,22553,22555,23222,23223,23225,23232,23233,23235,23252,
            23253,23255,23322,23323,23325,23332,23333,23335,23352,23353,23355,23522,23523,23525,23532,23533,
            23535,23552,23553,23555,25222,25223,25225,25232,25233,25235,25252,25253,25255,25322,25323,25325,
            25332,25333,25335,25352,25353,25355,25522,25523,25525,25532,25533,25535,25552,25553,25555,32222,
            32223,32225,32232,32233,32235,32252,32253,32255,32322,32323,32325,32332,32333,32335,32352,32353,
            32355,32522,32523,32525,32532,32533,32535,32552,32553,32555,33222,33223,33225,33232,33233,33235,
            33252,33253,33255,33322,33323,33325,33332,33333,33335,33352,33353,33355,33522,33523,33525,33532,
            33533,33535,33552,33553,33555,35222,35223,35225,35232,35233,35235,35252,35253,35255,35322,35323,
            35325,35332,35333,35335,35352,35353,35355,35522,35523,35525,35532,35533,35535,35552,35553,35555,
            52222,52223,52225,52232,52233,52235,52252,52253,52255,52322,52323,52325,52332,52333,52335,52352,
            52353,52355,52522,52523,52525,52532,52533,52535,52552,52553,52555,53222,53223,53225,53232,53233,
            53235,53252,53253,53255,53322,53323,53325,53332,53333,53335,53352,53353,53355,53522,53523,53525,
            53532,53533,53535,53552,53553,53555,55222,55223,55225,55232,55233,55235,55252,55253,55255,55322,
            55323,55325,55332,55333,55335,55352,55353,55355,55522,55523,55525,55532,55533,55535,55552,55553,
            55555,222222,222223,222225,222232,222233,222235,222252,222253,222255,222322,222323,222325,222332,
            222333,222335,222352,222353,222355,222522,222523,222525,222532,222533,222535,222552,222553,222555,
            223222,223223,223225,223232,223233,223235,223252,223253,223255,223322,223323,223325,223332,223333,
            223335,223352,223353,223355,223522,223523,223525,223532,223533,223535,223552,223553,223555,225222,
            225223,225225,225232,225233,225235,225252,225253,225255,225322,225323,225325,225332,225333,225335,
            225352,225353,225355,225522,225523,225525,225532,225533,225535,225552,225553,225555,232222,232223,
            232225,232232,232233,232235,232252,232253,232255,232322,232323,232325,232332,232333,232335,232352,
            232353,232355,232522,232523,232525,232532,232533,232535,232552,232553,232555,233222,233223,233225,
            233232,233233,233235,233252,233253,233255,233322,233323,233325,233332,233333,233335,233352,233353,
            233355,233522,233523,233525,233532,233533,233535,233552,233553,233555,235222,235223,235225,235232,
            235233,235235,235252,235253,235255,235322,235323,235325,235332,235333,235335,235352,235353,235355,
            235522,235523,235525,235532,235533,235535,235552,235553,235555,252222,252223,252225,252232,252233,
            252235,252252,252253,252255,252322,252323,252325,252332,252333,252335,252352,252353,252355,252522,
            252523,252525,252532,252533,252535,252552,252553,252555,253222,253223,253225,253232,253233,253235,
            253252,253253,253255,253322,253323,253325,253332,253333,253335,253352,253353,253355,253522,253523,
            253525,253532,253533,253535,253552,253553,253555,255222,255223,255225,255232,255233,255235,255252,
            255253,255255,255322,255323,255325,255332,255333,255335,255352,255353,255355,255522,255523,255525,
            255532,255533,255535,255552,255553,255555,322222,322223,322225,322232,322233,322235,322252,322253,
            322255,322322,322323,322325,322332,322333,322335,322352,322353,322355,322522,322523,322525,322532,
            322533,322535,322552,322553,322555,323222,323223,323225,323232,323233,323235,323252,323253,323255,
            323322,323323,323325,323332,323333,323335,323352,323353,323355,323522,323523,323525,323532,323533,
            323535,323552,323553,323555,325222,325223,325225,325232,325233,325235,325252,325253,325255,325322,
            325323,325325,325332,325333,325335,325352,325353,325355,325522,325523,325525,325532,325533,325535,
            325552,325553,325555,332222,332223,332225,332232,332233,332235,332252,332253,332255,332322,332323,
            332325,332332,332333,332335,332352,332353,332355,332522,332523,332525,332532,332533,332535,332552,
            332553,332555,333222,333223,333225,333232,333233,333235,333252,333253,333255,333322,333323,333325,
            333332,333333,333335,333352,333353,333355,333522,333523,333525,333532,333533,333535,333552,333553,
            333555,335222,335223,335225,335232,335233,335235,335252,335253,335255,335322,335323,335325,335332,
            335333,335335,335352,335353,335355,335522,335523,335525,335532,335533,335535,335552,335553,335555,
            352222,352223,352225,352232,352233,352235,352252,352253,352255,352322,352323,352325,352332,352333,
            352335,352352,352353,352355,352522,352523,352525,352532,352533,352535,352552,352553,352555,353222,
            353223,353225,353232,353233,353235,353252,353253,353255,353322,353323,353325,353332,353333,353335,
            353352,353353,353355,353522,353523,353525,353532,353533,353535,353552,353553,353555,355222,355223,
            355225,355232,355233,355235,355252,355253,355255,355322,355323,355325,355332,355333,355335,355352,
            355353,355355,355522,355523,355525,355532,355533,355535,355552,355553,355555,522222,522223,522225,
            522232,522233,522235,522252,522253,522255,522322,522323,522325,522332,522333,522335,522352,522353,
            522355,522522,522523,522525,522532,522533,522535,522552,522553,522555,523222,523223,523225,523232,
            523233,523235,523252,523253,523255,523322,523323,523325,523332,523333,523335,523352,523353,523355,
            523522,523523,523525,523532,523533,523535,523552,523553,523555,525222,525223,525225,525232,525233,
            525235,525252,525253,525255,525322,525323,525325,525332,525333,525335,525352,525353,525355,525522,
            525523,525525,525532,525533,525535,525552,525553,525555,532222,532223,532225,532232,532233,532235,
            532252,532253,532255,532322,532323,532325,532332,532333,532335,532352,532353,532355,532522,532523,
            532525,532532,532533,532535,532552,532553,532555,533222,533223,533225,533232,533233,533235,533252,
            533253,533255,533322,533323,533325,533332,533333,533335,533352,533353,533355,533522,533523,533525,
            533532,533533,533535,533552,533553,533555,535222,535223,535225,535232,535233,535235,535252,535253,
            535255,535322,535323,535325,535332,535333,535335,535352,535353,535355,535522,535523,535525,535532,
            535533,535535,535552,535553,535555,552222,552223,552225,552232,552233,552235,552252,552253,552255,
            552322,552323,552325,552332,552333,552335,552352,552353,552355,552522,552523,552525,552532,552533,
            552535,552552,552553,552555,553222,553223,553225,553232,553233,553235,553252,553253,553255,553322,
            553323,553325};


    public int getNum(int n){
        Queue<Integer> queue = new LinkedList<>();
        queue.add(2);
        queue.add(3);
        queue.add(5);
        int k = n;
        while(k>0){
            int cur = queue.poll();
            nums.add(cur);
            k--;
            for(int i = 0; i<3; i++){
                int newCount = cur;
                newCount *= 10;
                newCount += num[i];
                queue.offer(newCount);
            }
        }
        return queue.peek();
    }



    @Test
    public void test(){
        System.out.println(getNum(1050));
        nums.forEach(e -> System.out.print(e + ","));
    }
}
